package com.adcc.loadsheet.monitor.vo;


import com.adcc.loadsheet.monitor.entity.BaseEntity;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.collect.Maps;

import java.util.Map;

/**
 * 结果集视图对象
 * @param <T>
 */
public class ResultVO<T extends BaseVO> extends BaseVO{

    /**
     * 请求参数无效
     */
    public static final String ER_PARAMS_INVALID = "input parameter %s invalid";

    /**
     * 调用服务失败
     */
    public static final String ER_CALL_FAILED = "call %s failed";

    /**
     * 调用服务失败
     */
    public static final String ER_CALL_EX_FAILED = "call %s failed %s";

    // 状态
    private ResultStatus status = ResultStatus.SUCCESS;

    // 异常原因
    private String errorReason = "";

    // 数据集
    private Map<String, Object> data = Maps.newHashMap();

    public ResultStatus getStatus() {
        return status;
    }

    public void setStatus(ResultStatus status) {
        this.status = status;
    }

    public String getErrorReason() {
        return errorReason;
    }

    public void setErrorReason(String errorReason) {
        this.errorReason = errorReason;
    }

    public Map<String, Object> getData() {
        return data;
    }

    public void setData(Map<String, Object> data) {
        this.data = data;
    }

    @Override
    public BaseEntity toEntity() {
        return null;
    }

    @Override
    public String toJSON() throws JsonProcessingException {
        return JSON.toJSONString(this);
    }
}
